package org.cainiao.scenario.highconcurrency.config;

import org.redisson.api.RBloomFilter;
import org.redisson.api.RedissonClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

// 配置类中初始化布隆过滤器
@Configuration
public class BloomFilterConfig {

    @Bean
    public RBloomFilter<String> userIdBloomFilter(RedissonClient redissonClient) {
        RBloomFilter<String> bloomFilter = redissonClient.getBloomFilter("userIdBloomFilter");
        // 初始化：预期元素数量100万，误判率1%
        bloomFilter.tryInit(1_000_000L, 0.01);
        return bloomFilter;
    }
}
